#include "wen_bvh.h"

using namespace wen;

BVH::BVH()
{
	m_iMaxX = 0.0f;
	m_iMinX = 0.0f;
	m_iMaxY = 0.0f;
	m_iMinY = 0.0f;
	m_iMaxZ = 0.0f;
	m_iMinZ = 0.0f;

	m_pkMaxVertex = new D3DXVECTOR3(0.0f, 0.0f, 0.0f);
	m_pkMinVertex = new D3DXVECTOR3(0.0f, 0.0f, 0.0f);	
}

BVH::~BVH()
{
	delete m_pkMaxVertex;
	m_pkMaxVertex = NULL;	

	delete m_pkMinVertex;
	m_pkMinVertex = NULL;
}

void BVH::SetBVHBoxVertices(float maxX, float minX, float maxY, float minY, float maxZ, float minZ)
{
	m_iMaxX = maxX;
	m_iMinX = minX;
	m_iMaxY = maxY;
	m_iMinY = minY;
	m_iMaxZ = maxZ;
	m_iMinZ = minZ;

	m_pkMaxVertex->x = m_iMaxX;
	m_pkMaxVertex->y = m_iMaxY;
	m_pkMaxVertex->z = m_iMaxZ;

	m_pkMinVertex->x = m_iMinX;
	m_pkMinVertex->y = m_iMinY;
	m_pkMinVertex->z = m_iMinZ;
}

void BVH::TransformBVHVertex(const D3DXMATRIX* transformMatrix)
{
	//D3DXVECTOR3 maxOut;
	D3DXVec3TransformCoord(m_pkMaxVertex, m_pkMaxVertex, transformMatrix);

	//D3DXVECTOR3 minOut;
	D3DXVec3TransformCoord(m_pkMinVertex, m_pkMinVertex, transformMatrix);
}